
/**
 * 日期格式化
 * @param v
 * @param type
 * @returns {string}
 * @constructor
 */
function FormatTime(v,type){
    if (v===null || $.trim(v)===""){
        return "";
    }
	var date = new Date(v);
    var y = date.getFullYear();
    var m = date.getMonth()+1;
    m = m<10?'0'+m:m;
    var d = date.getDate();
    d = d<10?("0"+d):d;
    var h = date.getHours();
    h = h<10?("0"+h):h;
    var M = date.getMinutes();
    M = M<10?("0"+M):M;
    var s = date.getSeconds();
    s = s<10?("0"+s):s;
    var str;
    if(type == 0){
        str = y+"-"+m+"-"+d;
    }else{
        str = y+"-"+m+"-"+d+" "+h+":"+M+":"+s;
    }

    return str;
}

/**
 * 格式化日期时间
 * @param v 日期时间
 * @returns {string}
 */
function formatDateTime(v){
    if (v===null || $.trim(v)===""){
        return "";
    }
    let date = new Date(v);
    let y = date.getFullYear();
    let m = date.getMonth()+1;
    m = m<10?'0'+m:m;
    let d = date.getDate();
    d = d<10?("0"+d):d;
    let h = date.getHours();
    h = h<10?("0"+h):h;
    let M = date.getMinutes();
    M = M<10?("0"+M):M;
    let s = date.getSeconds();
    s = s<10?("0"+s):s;
    return y + "-" + m + "-" + d + " " + h + ":" + M + ":" + s;
}

function formatDateMin(v){
    if (v===null || $.trim(v)===""){
        return "";
    }
    let date = new Date(v);
    let y = date.getFullYear();
    let m = date.getMonth()+1;
    m = m<10?'0'+m:m;
    let d = date.getDate();
    d = d<10?("0"+d):d;
    let h = date.getHours();
    h = h<10?("0"+h):h;
    let M = date.getMinutes();
    M = M<10?("0"+M):M;
    return y + "-" + m + "-" + d + " " + h + ":" + M;
}

/**
 * 格式化日期
 * @param v 日期
 * @returns {string}
 */
function formatDate(v){
    if (v===null || $.trim(v)===""){
        return "";
    }
    let date = new Date(v);
    let y = date.getFullYear();
    let m = date.getMonth()+1;
    m = m<10?'0'+m:m;
    let d = date.getDate();
    d = d<10?("0"+d):d;

    return y + "-" + m + "-" + d;
}
